OBJEXT:=obj

include ../rules.mak

all:\
	$(TARGET_DIR)/springprox.dll \
	$(TARGET_DIR)/sprox_desfire.dll \
	$(TARGET_DIR)/sprox_mifulc.dll \
	$(TARGET_DIR)/sprox_calypso.dll \
	$(TARGET_DIR)/unicode/springprox.dll \
	$(TARGET_DIR)/stdcall/springprox.dll \
	$(TARGET_DIR)/springprox_ex.dll \
	$(TARGET_DIR)/sprox_desfire_ex.dll \
	$(TARGET_DIR)/sprox_mifulc_ex.dll


_SPRINGPROX_BARACODA_OBJS:=$(patsubst %.c,%.br.$(OBJEXT),$(SPRINGPROX_BARACODA_SRCS))
SPRINGPROX_BARACODA_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPRINGPROX_BARACODA_OBJS))

_SPRINGPROX_EX_OBJS:=$(patsubst %.c,%.ex.$(OBJEXT),$(SPRINGPROX_SRCS))
SPRINGPROX_EX_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPRINGPROX_EX_OBJS))

_SPRINGPROX_UN_OBJS:=$(patsubst %.c,%.un.$(OBJEXT),$(SPRINGPROX_SRCS))
SPRINGPROX_UN_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPRINGPROX_UN_OBJS))

_SPRINGPROX_ST_OBJS:=$(patsubst %.c,%.st.$(OBJEXT),$(SPRINGPROX_SRCS))
SPRINGPROX_ST_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPRINGPROX_ST_OBJS))

_SPROX_DESFIRE_EX_OBJS:=$(patsubst %.c,%.ex.$(OBJEXT),$(SPROX_DESFIRE_SRCS))
SPROX_DESFIRE_EX_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPROX_DESFIRE_EX_OBJS))

_SPROX_MIFULC_EX_OBJS:=$(patsubst %.c,%.ex.$(OBJEXT),$(SPROX_MIFULC_SRCS))
SPROX_MIFULC_EX_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPROX_MIFULC_EX_OBJS))

_SPROX_CALYPSO_EX_OBJS:=$(patsubst %.c,%.ex.$(OBJEXT),$(SPROX_CALYPSO_SRCS))
SPROX_CALYPSO_EX_OBJS:=$(subst $(SOURCE_DIR),$(OBJECT_DIR),$(_SPROX_CALYPSO_EX_OBJS))

$(TARGET_DIR)/springprox.dll: $(SPRINGPROX_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /implib:$(TARGET_DIR)/springprox.lib /out:$(TARGET_DIR)/springprox.dll $^ $(LDLIBS)

$(TARGET_DIR)/springprox_ex.dll: $(SPRINGPROX_EX_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/springprox_ex.dll /implib:$(TARGET_DIR)/springprox_ex.lib $^ $(LDLIBS)

$(TARGET_DIR)/unicode/springprox.dll: $(SPRINGPROX_ST_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/unicode/springprox.dll /implib:$(TARGET_DIR)/unicode/springprox.lib $^ $(LDLIBS)

$(TARGET_DIR)/stdcall/springprox.dll: $(SPRINGPROX_ST_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/stdcall/springprox.dll /implib:$(TARGET_DIR)/stdcall/springprox.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_desfire.dll: $(TARGET_DIR)/springprox.lib $(SPROX_DESFIRE_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_desfire.dll /implib:$(TARGET_DIR)/sprox_desfire.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_desfire_ex.dll: $(TARGET_DIR)/springprox_ex.lib $(SPROX_DESFIRE_EX_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_desfire_ex.dll /implib:$(TARGET_DIR)/sprox_desfire_ex.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_mifulc.dll: $(TARGET_DIR)/springprox.lib $(SPROX_MIFULC_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_mifulc.dll /implib:$(TARGET_DIR)/sprox_mifulc.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_mifulc_ex.dll: $(TARGET_DIR)/springprox_ex.lib $(SPROX_MIFULC_EX_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_mifulc_ex.dll /implib:$(TARGET_DIR)/sprox_mifulc_ex.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_calypso.dll: $(TARGET_DIR)/springprox.lib $(SPROX_CALYPSO_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_calypso.dll /implib:$(TARGET_DIR)/sprox_calypso.lib $^ $(LDLIBS)

$(TARGET_DIR)/sprox_calypso_ex.dll: $(TARGET_DIR)/springprox_ex.lib $(SPROX_CALYPSO_EX_OBJS)
	@echo #   building $@
	$(LD) $(LDFLAGS) /out:$(TARGET_DIR)/sprox_calypso_ex.dll /implib:$(TARGET_DIR)/sprox_calypso_ex.lib $^ $(LDLIBS)


CCFLAGS:=/X /I$(INCLUDE_DIR) /I$(SOURCE_DIR) /W3 /D WIN32 /Oxs /c 
LDFLAGS:=/dll /incremental:no /MACHINE:I386 /LIBPATH:$(LIBRARY_DIR)
LDLIBS:=kernel32.lib user32.lib gdi32.lib advapi32.lib

$(OBJECT_DIR)/%.$(OBJEXT): $(SOURCE_DIR)/%.c
	- @w:/mkdir -p $(subst /,\,$(dir $@))
	@echo # - compiling $(notdir $<)
	$(CC) $(CCFLAGS) /D SPROX_API /D SPROX_API_WITH_BRCD /TC /Fo$@ $<

$(OBJECT_DIR)/%.ex.$(OBJEXT): $(SOURCE_DIR)/%.c
	- @w:/mkdir -p $(subst /,\,$(dir $@))
	@echo # - compiling $(notdir $<) (EX)
	$(CC) $(CCFLAGS) /D SPROX_API /D SPROX_API_REENTRANT /TC /Fo$@ $<

$(OBJECT_DIR)/%.st.$(OBJEXT): $(SOURCE_DIR)/%.c
	- @w:/mkdir -p $(subst /,\,$(dir $@))
	@echo # - compiling $(notdir $<) (ST)
	$(CC) $(CCFLAGS) /D SPROX_API /D FORCE_STDCALL /TC /Fo$@ $<

$(OBJECT_DIR)/%.un.$(OBJEXT): $(SOURCE_DIR)/%.c
	- @w:/mkdir -p $(subst /,\,$(dir $@))
	@echo # - compiling $(notdir $<) (UN)
	$(CC) $(CCFLAGS) /D SPROX_API /D UNICODE /D _UNICODE /TC /Fo$@ $<
